﻿
namespace Mbs
{

    /// <summary>
    /// 保管人接口
    /// </summary>
    public interface ICaretaker
    {
        /// <summary>
        /// 得到备忘录对象
        /// </summary>
        /// <returns></returns>
        object Get();

        /// <summary>
        /// 保存备忘录对象
        /// </summary>
        /// <param name="memento"></param>
        void Save(object memento);
    }

    public interface ICaretaker<TMemento> : ICaretaker
    {
        /// <summary>
        /// 得到备忘录对象
        /// </summary>
        /// <returns></returns>
        new TMemento Get();

        /// <summary>
        /// 保存备忘录对象
        /// </summary>
        /// <param name="memento"></param>
        void Save(TMemento memento);
    }

    /// <summary>
    /// 发起人接口
    /// </summary>
    public interface IOriginator
    {
        /// <summary>
        /// 创建备忘录
        /// </summary>
        /// <returns></returns>
        object CreateMemento();
        /// <summary>
        /// 恢复备忘录
        /// </summary>
        /// <param name="properties"></param>
        void RestoreMemento(object memento);
    }

    public interface IOriginator<TMemento>:IOriginator
    {
        /// <summary>
        /// 创建备忘录
        /// </summary>
        /// <returns></returns>
        new TMemento CreateMemento();
        /// <summary>
        /// 恢复备忘录
        /// </summary>
        /// <param name="properties"></param>
        void RestoreMemento(TMemento memento);
    }
}
